<template>
  <div class="ev-message">
    <div class="content" :class="type ? `message-${type} ` : ''">
      <div class="close" @click="close"><i class="el-icon-close"></i></div>
      {{ content }}
    </div>
  </div>
</template>

<script>
// 自定义提示框
export default {
  name: "EvMessage",
  data() {
    return {
        type:'info',
        duration:3000,
        content:'请输入内容'
    };
  },
  mounted() {
    this.timer = setTimeout(() => {
      this.close();
    }, this.duration);
  },

  methods: {
    close() {
      clearTimeout(this.timer);
      this.$destroy(true);
      this.$el.parentNode.removeChild(this.$el);
    },
  },
};
</script>

<style lang="scss" scoped>
.ev-message {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  .content {
    width: 200px;
    height: 50px;
    line-height: 50px;
    border-radius: 5px;
    text-align: center;
    font-size: 16px;
    padding: 10px;
    color: #fff;
    position: relative;
    .close {
      position: absolute;
      top: -10px;
      right: 5px;
      cursor: pointer;
    }
  }
}
.message-info {
  background: rgb(224, 220, 212);
}
.message-success {
  background: rgb(57, 209, 27);
}
.message-error {
  background: rgb(211, 49, 49);
}
</style>
